<template>
  <div class="loginhome" style="overflow: auto">
    <!-- 头部 -->
    <div class="loginheader">
      <span
        class="el-icon-caret-left"
        @click="goback"
        style="cursor: pointer"
      ></span>
      <span>评论</span>
    </div>
    <!-- 评论区 -->

    <ul v-infinite-scroll="load">
      <li v-for="(item, index) in hotcomments" :key="index" class="listy">
        <div class="commentsty">
          <div class="imgdiv">
            <img :src="item.user.avatarUrl" class="imgsty" />
          </div>
          <div class="wenzi">
            {{ item.user.nickname }} <br />
            {{ item.timeStr }}
          </div>
        </div>
        <div class="content">{{ item.content }}</div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      hotcomments: [],
      user: [],
      count: 0,
    };
  },
  created() {
    var id = this.$route.query.id;
    this.id = id;
    this.getcomment();
  },
  methods: {
    load() {
      this.count += 2;
    },
    getcomment() {
      this.axios
        .get(`/comment/music?id=${this.id}&limit=3`)
        .then((res) => {
          this.hotcomments = res.data.hotComments;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 返回上一页
    goback() {
      this.$router.go(-1);
    },
  },
};
</script>

<style scoped>
.loginheader {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: red;
  border-bottom: red 1px solid;
  height: 30px;
}
.imgsty {
  height: 40px;
  width: 40px;
}
.listy {
  margin-top: 10px;
}
.wenzi {
  font-size: 14px;
  color: red;
  margin-left: 10px;
}

.content {
  margin-left: 50px;
  margin-bottom: 20px;
}
.commentsty {
  display: flex;
}
</style>